package com.yuyue.dronesystem.entities;

import java.util.Objects;

import javax.persistence.Convert;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.yuyue.dronesystem.enums.PlaceType;

/**
 * Site
 */
@Entity
@Table(name = "site_info")
public class Site {

    @Id // 这是一个主键
    @GeneratedValue(strategy = GenerationType.IDENTITY) // 自增主键
    private Integer id;
    private String name;
    @Embedded
    private Coordinate coor;
    @Enumerated(EnumType.STRING)
    private PlaceType type = PlaceType.OTHER;
    private Boolean isSource = true;

    public Site() {
    }

    public Site(Integer id, String name, Coordinate coor) {
        this.id = id;
        this.name = name;
        this.coor = coor;
    }

    public Site(Integer id, String name, Coordinate coor, PlaceType type, Boolean isSource) {
        this.id = id;
        this.name = name;
        this.coor = coor;
        this.type = type;
        this.isSource = isSource;
    }

    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Coordinate getCoor() {
        return this.coor;
    }

    public void setCoor(Coordinate coor) {
        this.coor = coor;
    }

    public PlaceType getType() {
        return this.type;
    }

    public void setType(PlaceType type) {
        this.type = type;
    }

    public Boolean isIsSource() {
        return this.isSource;
    }

    public Boolean getIsSource() {
        return this.isSource;
    }

    public void setIsSource(Boolean isSource) {
        this.isSource = isSource;
    }

    public Site id(Integer id) {
        this.id = id;
        return this;
    }

    public Site name(String name) {
        this.name = name;
        return this;
    }

    public Site coor(Coordinate coor) {
        this.coor = coor;
        return this;
    }

    public Site type(PlaceType type) {
        this.type = type;
        return this;
    }

    public Site isSource(Boolean isSource) {
        this.isSource = isSource;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this)
            return true;
        if (!(o instanceof Site)) {
            return false;
        }
        Site site = (Site) o;
        return Objects.equals(id, site.id) && Objects.equals(name, site.name) && Objects.equals(coor, site.coor) && Objects.equals(type, site.type) && Objects.equals(isSource, site.isSource);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, coor, type, isSource);
    }

    @Override
    public String toString() {
        return "{" +
            " id='" + getId() + "'" +
            ", name='" + getName() + "'" +
            ", coor='" + getCoor() + "'" +
            ", type='" + getType() + "'" +
            ", isSource='" + isIsSource() + "'" +
            "}";
    }
}